package org.dynobjects.core;

import java.util.ResourceBundle;

public class RuntimeCompilerFactory {

	private static final RuntimeCompiler DEFAULT_RUNTIME_COMPILER = new DefaultRuntimeCompiler();
	private static RuntimeCompiler compiler = DEFAULT_RUNTIME_COMPILER;
	private static ResourceBundle bundle = ResourceBundle.getBundle("dynamicobjects");

	public static RuntimeCompiler getRuntimeCompiler(){
		String compilerClass = bundle.getString("runtime.compiler");
		if(compilerClass!=null){
			try {
				compiler = (RuntimeCompiler) Class.forName(compilerClass).newInstance();
			} catch (InstantiationException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (IllegalAccessException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			} catch (ClassNotFoundException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
		}
		return compiler;
	}
}
